import token from "./token.js"
import user from "./user.js"
import myfetch from "../assets/myfetch"

function getMyWork() {
  let param = {
    id: token.getToken(user.getMyInfo().id)
  }
  return myfetch.myget("/work/getMywork", param)
}

function getMyDoWork() {
  let param = {
    id: token.getToken(user.getMyInfo().id)
  }
  return myfetch.myget("/work/getMyDowork", param)
}

function getPaper(id) {
  let param = {
    id,
    token: token.getToken()
  }
  return myfetch.myget("/work/getPaper", param)
}

function setCanSee(id, cansee) {
  let param = {
    id,
    cansee
  }
  return myfetch.myget("/work/setCanSee", param)
}

function delMyWork(workid) {
  let param = {
    id: token.getToken(user.getMyInfo().id),
    workid
  }
  return myfetch.myget("/work/delMyWork", param)
}

function addWork(body) {
  return myfetch.mypost("/work/add", {}, body)
}

function saveWork(body) {
  return myfetch.mypost("/work/save", {}, body)
}
export default {
  getMyWork,
  getMyDoWork,
  setCanSee,
  getPaper,
  delMyWork,
  addWork,
  saveWork
}
